// src/access.ts
// 具体配置可参考：https://umijs.org/plugins/plugin-access
export default function access(initialState: { currentUser?: API.CurrentUser | undefined, hasPermissions?: string[]}) {
    const {hasPermissions, currentUser} = initialState || {};
    // cas用户信息统一结构
    const {currentRole} = currentUser || {};
    const {nickName, id, tag} = currentRole || {};
    // 页面界别权限tag
    const tagSets = new Set(hasPermissions || []);
    return {
        canReadPageA: tagSets.has('gt_pageA'),
        // 示例：只有后端人员可以编辑
        canEditPageA: tagSets.has('gt_pageA') && nickName === 'rd',
        canReadPageB: tagSets.has('gt_pageB'),
        canReadPageC: tagSets.has('gt_pageC'),
        canReadPageD: tagSets.has('gt_pageD'),
    };
}
